import { takeEvery, put, call } from 'redux-saga/effects'
import { LOADDATASAGA } from './actionTypes'
import { loadDataForReducer } from './actionCreater'

import { get } from '@/utils/http'

function* loadData() {
  // let result = yield get({
  //   url: '/api/list'
  // })

  let result = yield call(get, { url: '/api/list' })
  // let result = yield call(get, { url: '/mock/cookbook-list.json' })

  yield put(loadDataForReducer(result.data.data))
}

function* saga() {
  yield takeEvery(LOADDATASAGA, loadData)
}

export default saga